public class ListAllThreads {

	public static void main(String[] args) {
		new PrintNameThread("A");
		new PrintNameThread("B");
		new PrintNameThread("C");

		ThreadGroup threadGroup = Thread.currentThread().getThreadGroup().getParent();
		
		Thread[] list = extracted(threadGroup);
		
		for (Thread thread : list) {
			System.out.println("Thread " +thread + thread.getThreadGroup().getName());
		}
	}

	private static Thread[] extracted(ThreadGroup threadGroup) {
		Thread[] list= new Thread[threadGroup.activeCount()];
		threadGroup.enumerate(list);
		return list;
	}
}
